﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OracleClient;
using System.Data;
using EntitiesLayer.Entities;


namespace DataLayer.DAO
{
    public class ServicioNoConformeDAO
    {
        private Connection.Connection cn;
        private OracleConnection objCn;

        public ServicioNoConformeDAO()
        {
            cn = new Connection.Connection();
            objCn = cn.Conecta();
        }

        public List<ServicioNoConforme> Listado_SNC_Email(string CodSnc)
        {
            List<ServicioNoConforme> lstObject = new List<ServicioNoConforme>();
            try
            {
                OracleCommand cmd = new OracleCommand("LISTADO_SNC_EMAIL", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("RECORDSET", OracleType.Cursor, 100, ParameterDirection.Output, null, DataRowVersion.Current, false, null));
                cmd.Parameters.Add(new OracleParameter("Rsnc_Cod_Snc", OracleType.VarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, CodSnc));

                using (IDataReader oRead = cmd.ExecuteReader(CommandBehavior.SingleResult))
                {
                    if (oRead != null)
                    {
                        while (oRead.Read())
                        {
                            ServicioNoConforme obj = new ServicioNoConforme();

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vsnc_Desc_Snc")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetDateTime(oRead.GetOrdinal("Vsnc_Desc_Snc")).ToString()))
                                {
                                    obj.VSNC_DESC_SNC = oRead.GetString(oRead.GetOrdinal("Vsnc_Desc_Snc"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vemp_Nro_Documento")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vemp_Nro_Documento")).ToString()))
                                {
                                    obj.VEMP_NRO_DOCUMENTO = oRead.GetString(oRead.GetOrdinal("Vemp_Nro_Documento"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vsed_Desc_Sede")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vsed_Desc_Sede")).ToString()))
                                {
                                    obj.VSED_DESC_SEDE = oRead.GetString(oRead.GetOrdinal("Vsed_Desc_Sede"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vneg_Desc_Uni_Neg")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vneg_Desc_Uni_Neg")).ToString()))
                                {
                                    obj.VNEG_DESC_UNI_NEG = oRead.GetString(oRead.GetOrdinal("Vneg_Desc_Uni_Neg"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vser_Desc_Serv")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vser_Desc_Serv")).ToString()))
                                {
                                    obj.VSER_DESC_SERV = oRead.GetString(oRead.GetOrdinal("Vser_Desc_Serv"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vare_Desc_Area")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vare_Desc_Area")).ToString()))
                                {
                                    obj.VARE_DESC_AREA = oRead.GetString(oRead.GetOrdinal("Vare_Desc_Area"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vgen_Desc_Mot_Gen")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vgen_Desc_Mot_Gen")).ToString()))
                                {
                                    obj.VGEN_DESC_MOT_GEN = oRead.GetString(oRead.GetOrdinal("Vgen_Desc_Mot_Gen"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vesp_Desc_Mot_Esp")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vesp_Desc_Mot_Esp")).ToString()))
                                {
                                    obj.VESP_DESC_MOT_ESP = oRead.GetString(oRead.GetOrdinal("Vesp_Desc_Mot_Esp"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vque_Desc_Tip_Que")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vque_Desc_Tip_Que")).ToString()))
                                {
                                    obj.VQUE_DESC_TIP_QUE = oRead.GetString(oRead.GetOrdinal("Vque_Desc_Tip_Que"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vest_Nombreestado")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vest_Nombreestado")).ToString()))
                                {
                                    obj.VEST_NOMBREESTADO = oRead.GetString(oRead.GetOrdinal("Vest_Nombreestado"));
                                }
                            }


                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vts_Des_Tipo_Solicitud")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vts_Des_Tipo_Solicitud")).ToString()))
                                {
                                    obj.VTS_DES_TIPO_SOLICITUD = oRead.GetString(oRead.GetOrdinal("Vts_Des_Tipo_Solicitud"));
                                }
                            }

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vpro_Raz_Soc_Prov")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("Vpro_Raz_Soc_Prov")).ToString()))
                                {
                                    obj.VPRO_RAZ_SOC_PROV = oRead.GetString(oRead.GetOrdinal("Vpro_Raz_Soc_Prov"));
                                }
                            }
                            lstObject.Add(obj);
                            obj = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                objCn.Close();
            }

            return lstObject;

        }


        public List<ServicioNoConforme> Listado_SNC_Email_Area(string CodSnc)
        {
            List<ServicioNoConforme> lstObject = new List<ServicioNoConforme>();
            try
            {
                OracleCommand cmd = new OracleCommand("LISTADO_SNC_EMAIL_AREA", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("RECORDSET", OracleType.Cursor, 100, ParameterDirection.Output, null, DataRowVersion.Current, false, null));
                cmd.Parameters.Add(new OracleParameter("Rsnc_Cod_Snc", OracleType.VarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, CodSnc));

                using (IDataReader oRead = cmd.ExecuteReader(CommandBehavior.SingleResult))
                {
                    if (oRead != null)
                    {
                        while (oRead.Read())
                        {
                            ServicioNoConforme obj = new ServicioNoConforme();

                            if (!oRead.IsDBNull(oRead.GetOrdinal("Vare_Desc_Area")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetDateTime(oRead.GetOrdinal("Vare_Desc_Area")).ToString()))
                                {
                                    obj.VARE_DESC_AREA = oRead.GetString(oRead.GetOrdinal("Vare_Desc_Area"));
                                }
                            }

                            lstObject.Add(obj);
                            obj = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                objCn.Close();
            }

            return lstObject;

        }




        public List<ServicioNoConforme> Listado_Email_Area_Involu(string CodSnc)
        {
            List<ServicioNoConforme> lstObject = new List<ServicioNoConforme>();
            try
            {
                OracleCommand cmd = new OracleCommand("Listado_Email_Area_Involu", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("RECORDSET", OracleType.Cursor, 100, ParameterDirection.Output, null, DataRowVersion.Current, false, null));
                cmd.Parameters.Add(new OracleParameter("Rsnc_Cod_Snc", OracleType.VarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, CodSnc));

                using (IDataReader oRead = cmd.ExecuteReader(CommandBehavior.SingleResult))
                {
                    if (oRead != null)
                    {
                        while (oRead.Read())
                        {
                            ServicioNoConforme obj = new ServicioNoConforme();

                            if (!oRead.IsDBNull(oRead.GetOrdinal("VEMP_EMAIL")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("VEMP_EMAIL")).ToString()))
                                {
                                    obj.VEMP_EMAIL = oRead.GetString(oRead.GetOrdinal("VEMP_EMAIL"));
                                }
                            }

                            lstObject.Add(obj);
                            obj = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                objCn.Close();
            }

            return lstObject;

        }

        public List<ServicioNoConforme> Listado_Email_A_InNC(string CodSnc)
        {
            List<ServicioNoConforme> lstObject = new List<ServicioNoConforme>();
            try
            {
                OracleCommand cmd = new OracleCommand("Listado_Email_A_InNC", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("RECORDSET", OracleType.Cursor, 100, ParameterDirection.Output, null, DataRowVersion.Current, false, null));
                cmd.Parameters.Add(new OracleParameter("Rnc_Codigo", OracleType.VarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, CodSnc));

                using (IDataReader oRead = cmd.ExecuteReader(CommandBehavior.SingleResult))
                {
                    if (oRead != null)
                    {
                        while (oRead.Read())
                        {
                            ServicioNoConforme obj = new ServicioNoConforme();

                            if (!oRead.IsDBNull(oRead.GetOrdinal("VEMP_EMAIL")))
                            {
                                if (!string.IsNullOrEmpty(oRead.GetString(oRead.GetOrdinal("VEMP_EMAIL")).ToString()))
                                {
                                    obj.VEMP_EMAIL = oRead.GetString(oRead.GetOrdinal("VEMP_EMAIL"));
                                }
                            }

                            lstObject.Add(obj);
                            obj = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                objCn.Close();
            }

            return lstObject;

        }



        public int insertSNC(ServicioNoConforme snc)
        {
            int resultado = 0;

            using (OracleCommand cmd1 = new OracleCommand("INSERTSERVICIONOCONFORME", objCn))
            {
                cmd1.CommandType = CommandType.StoredProcedure;

                OracleParameter refParameter = new OracleParameter("R_Codigo_Generado", OracleType.VarChar, 30);
                refParameter.Direction = ParameterDirection.Output;

                OracleParameter snc1 = new OracleParameter("R_Cod_Snc", OracleType.VarChar, 30);
                snc1.Value = snc.CodSNC;

                OracleParameter snc2 = new OracleParameter("R_Desc_Snc", OracleType.VarChar, 4000);
                snc2.Value = snc.DesSNC;

                OracleParameter snc3 = new OracleParameter("R_Nro_Documento", OracleType.VarChar, 15);
                snc3.Value = snc.NumDocEmpleado;

                OracleParameter snc4 = new OracleParameter("R_Cod_Sede", OracleType.VarChar, 10);
                snc4.Value = snc.CodSede;

                OracleParameter snc5 = new OracleParameter("R_Cod_Uni_Neg", OracleType.VarChar, 10);
                snc5.Value = snc.CodUniNego;

                OracleParameter snc6 = new OracleParameter("R_Cod_Serv", OracleType.VarChar, 10);
                snc6.Value = snc.CodServicio;

                OracleParameter snc7 = new OracleParameter("R_Cod_Area", OracleType.VarChar, 10);
                snc7.Value = snc.CodArea;

                OracleParameter snc8 = new OracleParameter("R_Cod_Prov", OracleType.VarChar, 10);
                snc8.Value = snc.CodProveedor;

                OracleParameter snc9 = new OracleParameter("R_Cod_Tip_Que", OracleType.VarChar, 10);
                snc9.Value = snc.CodTipoQueja;

                OracleParameter snc11 = new OracleParameter("R_Fecha_Registro", OracleType.DateTime);
                snc11.Value = snc.FechaRegistroSNC;

                OracleParameter snc13 = new OracleParameter("Rrec_Usuario_Creacion", OracleType.VarChar, 20);
                snc13.Value = snc.Rrec_Usuario_Creacion;

                OracleParameter snc14 = new OracleParameter("Rrec_Fecha_Vencimiento", OracleType.DateTime);
                snc14.Value = snc.Dsnc_Fecha_Vencimiento;

                cmd1.Parameters.Add(refParameter);
                cmd1.Parameters.Add(snc1);
                cmd1.Parameters.Add(snc2);
                cmd1.Parameters.Add(snc3);
                cmd1.Parameters.Add(snc4);
                cmd1.Parameters.Add(snc5);
                cmd1.Parameters.Add(snc6);
                cmd1.Parameters.Add(snc7);
                cmd1.Parameters.Add(snc8);
                cmd1.Parameters.Add(snc9);
                cmd1.Parameters.Add(snc11);
                cmd1.Parameters.Add(snc13);
                cmd1.Parameters.Add(snc14);

                try
                {
                    objCn.Open();

                    resultado = cmd1.ExecuteNonQuery();

                    if (resultado > 0)
                    {

                        using (OracleCommand cmd2 = new OracleCommand("INSERTDETALLESERVNOCONFORME", objCn))
                        {
                            cmd2.CommandType = CommandType.StoredProcedure;
                            foreach (ServicioNoConforme.Item item in snc.ListaItems)
                            {
                                OracleParameter dt1 = new OracleParameter("R_COD_SNC", OracleType.VarChar, 30);
                                dt1.Value = snc.CodSNC;
                                OracleParameter dt2 = new OracleParameter("R_COD_AREA", OracleType.VarChar, 10);
                                dt2.Value = item.CodOtraArea;
                                cmd2.Parameters.Clear();
                                cmd2.Parameters.Add(dt1);
                                cmd2.Parameters.Add(dt2);
                                cmd2.ExecuteNonQuery();
                            }
                            return resultado;
                        }
                    }
                    else
                    {
                        return 0;
                    }

                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return resultado;
        }

        public List<ServicioNoConforme> consultarServicioNoConforme(string codigo, string descripcion, string area)
        {
            List<ServicioNoConforme> list = new List<ServicioNoConforme>();

            using (OracleCommand cmd = new OracleCommand("BUSCARSEGUIMIENTOSNC", objCn))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter refParameter = new OracleParameter();
                refParameter.ParameterName = "RECORDSET";
                refParameter.OracleType = OracleType.Cursor;
                refParameter.Direction = ParameterDirection.Output;

                OracleParameter codigoParameter = new OracleParameter();
                codigoParameter.ParameterName = "v_codigo";
                codigoParameter.OracleType = OracleType.NVarChar;
                codigoParameter.Size = 100;
                codigoParameter.Direction = ParameterDirection.Input;
                codigoParameter.Value = codigo.Trim().ToLower();

                OracleParameter descripcionParameter = new OracleParameter();
                descripcionParameter.ParameterName = "v_descripcion";
                descripcionParameter.OracleType = OracleType.NVarChar;
                descripcionParameter.Size = 100;
                descripcionParameter.Direction = ParameterDirection.Input;
                descripcionParameter.Value = descripcion.Trim().ToLower();

                OracleParameter areaParameter = new OracleParameter();
                areaParameter.ParameterName = "v_area";
                areaParameter.OracleType = OracleType.NVarChar;
                areaParameter.Size = 100;
                areaParameter.Direction = ParameterDirection.Input;
                areaParameter.Value = area;

                cmd.Parameters.Add(refParameter);
                cmd.Parameters.Add(codigoParameter);
                cmd.Parameters.Add(descripcionParameter);
                cmd.Parameters.Add(areaParameter);

                try
                {
                    objCn.Open();

                    OracleDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        ServicioNoConforme snc = new ServicioNoConforme();
                        snc.CodSNC = Convert.ToString(dr[0]);
                        snc.DesSNC = Convert.ToString(dr[1]);
                        snc.FechaRegistroSNC = Convert.ToDateTime(dr[2]);
                        snc.CodSede = Convert.ToString(dr[3]);
                        snc.CodUniNego = Convert.ToString(dr[4]);
                        snc.CodServicio = Convert.ToString(dr[5]);
                        snc.CodArea = Convert.ToString(dr[6]);
                        snc.CodProveedor = Convert.ToString(dr[7]);
                        snc.CodTipoQueja = Convert.ToString(dr[8]);
                        snc.PlazoCantidad = Convert.ToInt32(dr[9]);
                        snc.PlazoUnidad = Convert.ToString(dr[10]);
                        snc.NumDocEmpleado = Convert.ToString(dr[11]);
                        snc.NombresEmpleado = Convert.ToString(dr[12]);
                        snc.Dsnc_Fecha_Vencimiento = Convert.ToString(dr[13]);

                        list.Add(snc);
                    }
                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return list;
        }

        public ServicioNoConforme obtenerSNC(string codigoSNC)
        {
            ServicioNoConforme snc = new ServicioNoConforme();

            using (OracleCommand cmd = new OracleCommand("BUSCARSNCXCODIGO", objCn))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter refParameter = new OracleParameter();
                refParameter.ParameterName = "RECORDSET";
                refParameter.OracleType = OracleType.Cursor;
                refParameter.Direction = ParameterDirection.Output;

                OracleParameter codigoParameter = new OracleParameter();
                codigoParameter.ParameterName = "R_COD_SNC";
                codigoParameter.OracleType = OracleType.NVarChar;
                codigoParameter.Size = 30;
                codigoParameter.Direction = ParameterDirection.Input;
                codigoParameter.Value = codigoSNC;

                cmd.Parameters.Add(refParameter);
                cmd.Parameters.Add(codigoParameter);

                try
                {
                    objCn.Open();

                    OracleDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        snc.DesSNC = Convert.ToString(dr[0]);
                        snc.NumDocEmpleado = Convert.ToString(dr[1]);
                        snc.CodArea = Convert.ToString(dr[2]);
                    }
                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return snc;
        }

        public int getSecuencia()
        {
            int secuencia = 0;

            using (OracleCommand cmd = new OracleCommand("SECUENCIASNC", objCn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                OracleParameter refparameter = new OracleParameter();
                refparameter.ParameterName = "RECORDSET";
                refparameter.OracleType = OracleType.Cursor;
                refparameter.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(refparameter);

                try
                {
                    objCn.Open();

                    OracleDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        secuencia = Convert.ToInt32(dr[0]);
                    }
                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return secuencia;
        }

        public int updateSeguimientoSNC(ServicioNoConforme snc)
        {
            int resultado = 0;

            using (OracleCommand cmd = new OracleCommand("UPDATESEGUIMIENTOSNC", objCn))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter snc1 = new OracleParameter("R_COD_SNC", OracleType.VarChar, 30);
                snc1.Value = snc.CodSNC;

                OracleParameter snc2 = new OracleParameter("R_COD_MOT_GEN", OracleType.VarChar, 10);
                snc2.Value = snc.CodMotivoGeneral;

                OracleParameter snc3 = new OracleParameter("R_COD_MOT_ESP", OracleType.VarChar, 10);
                snc3.Value = snc.CodMotivoEspecifico;

                OracleParameter snc4 = new OracleParameter("R_CODESTADO", OracleType.VarChar, 20);
                snc4.Value = snc.CodEstado;

                cmd.Parameters.Add(snc1);
                cmd.Parameters.Add(snc2);
                cmd.Parameters.Add(snc3);
                cmd.Parameters.Add(snc4);

                try
                {
                    objCn.Open();

                    resultado = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return resultado;
        }

        public int updateSNC(ServicioNoConforme snc)
        {
            int resultado = 0;

            using (OracleCommand cmd = new OracleCommand("UPDATESNC", objCn))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter snc1 = new OracleParameter("R_COD_SNC", OracleType.VarChar, 30);
                snc1.Value = snc.CodSNC;

                OracleParameter snc2 = new OracleParameter("R_COD_SEDE", OracleType.VarChar, 10);
                snc2.Value = snc.CodSede;

                OracleParameter snc3 = new OracleParameter("R_COD_UNI_NEG", OracleType.VarChar, 10);
                snc3.Value = snc.CodUniNego;

                OracleParameter snc4 = new OracleParameter("R_COD_SERV", OracleType.VarChar, 10);
                snc4.Value = snc.CodServicio;

                OracleParameter snc5 = new OracleParameter("R_COD_AREA", OracleType.VarChar, 10);
                snc5.Value = snc.CodArea;

                OracleParameter snc6 = new OracleParameter("R_COD_PROV", OracleType.VarChar, 10);
                snc6.Value = snc.CodProveedor;

                OracleParameter snc7 = new OracleParameter("R_COD_TIP_QUE", OracleType.VarChar, 10);
                snc7.Value = snc.CodTipoQueja;

                OracleParameter snc8 = new OracleParameter("R_DESC_SNC", OracleType.VarChar, 4000);
                snc8.Value = snc.DesSNC;

                OracleParameter snc9 = new OracleParameter("R_NRO_DOCUMENTO", OracleType.VarChar, 15);
                snc9.Value = snc.NumDocEmpleado;

                OracleParameter snc10 = new OracleParameter("R_FEC_VENCIMIENTO", OracleType.DateTime);
                snc10.Value = Convert.ToDateTime(snc.Dsnc_Fecha_Vencimiento);

                cmd.Parameters.Add(snc1);
                cmd.Parameters.Add(snc2);
                cmd.Parameters.Add(snc3);
                cmd.Parameters.Add(snc4);
                cmd.Parameters.Add(snc5);
                cmd.Parameters.Add(snc6);
                cmd.Parameters.Add(snc7);
                cmd.Parameters.Add(snc8);
                cmd.Parameters.Add(snc9);
                cmd.Parameters.Add(snc10);

                try
                {
                    objCn.Open();

                    resultado = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    objCn.Dispose();
                }
                finally
                {
                    objCn.Close();
                }
            }
            return resultado;
        }

    }
}
